/**
 * 资金预算管理初始化
 */
var ProfitLoss = {
    id: "ProfitLossTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    //clickToSelect: false,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
ProfitLoss.initColumn = function () {
    return [
        [
			{field: 'selectItem', radio: true,visible: false,colspan: 1,rowspan: 2,width:'36px'},
            {
                field: 'number',
                title: "序号",
                valign:"middle",
                align:"center",
                colspan: 1,
                rowspan: 2
            },
            {
                field: 'project',
                title: "项目",
                halign :"center",
                valign:"middle",
                align:"left",
                colspan: 1,
                rowspan: 2
            },

            {
                title: "本期金额",
                valign:"middle",
                align:"center",
                colspan: 2,
                rowspan: 1
            },
            {
                field: 'yearTotal',
                title: "本年累计",
                halign:"center",
                valign:"middle",
                align:"right",
                colspan: 1,
                rowspan: 2
            }

        ],
        [
            {
                field: 'piso',
                title: "PISO",
                halign :"center",
                valign:"middle",
                align:"right"
            },
            {
                field: 'rmb',
                title: "折合人民币",
                halign :"center",
                valign:"middle",
                align:"right"
            }

        ]



    ];
};

/**
 * 检查是否选中
 */
ProfitLoss.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        CapitalBudget.seItem = selected[0];
        return true;
    }
};


ProfitLoss.checkPayTime = function(){
    var revDate =  $("#revDate").val();
    if (revDate==null||revDate==""){
        Feng.info("请选择要导出的工资表时间");
        return false;
    } else {
        return true;
    }
};


/**
 * 导出
 */
ProfitLoss.exportProfitLoss = function () {
    if (this.checkPayTime()) {
        window.location.href = "/profitLoss/load?revDate=" + $("#revDate").val();
    }


};




/**
 * 查询资金预算列表
 */
ProfitLoss.search = function () {
    var queryData = {};
    queryData['revDate'] = $("#revDate").val();
    queryData['platform'] = $("#platform").val();
    ProfitLoss.table.refresh({query: queryData});


};

$(function () {
    var defaultColunms = ProfitLoss.initColumn();
    var table = new BSTable(ProfitLoss.id, "/profitLoss/getProfitLoss", defaultColunms,ProfitLoss);
    table.height=750;
    table.pagination=false;
    table.setPaginationType("client");
    table.setSize(50);
	table.setShowColumns(false);
	table.setShowRefresh(false);
    ProfitLoss.table = table.init();
	//添加表头
	$(".fixed-table-toolbar").after("<div style='text-align: center;vertical-align: middle;font-size: 22px;color: #6979d7;font-weight: bold;'> 损益表</div>");
});
